<?php
namespace App\Services;

use App\Models\Order;
use App\Models\OrderGoods;
use App\Models\User;
use Illuminate\Support\Facades\DB;
use Ramsey\Uuid\Uuid;

class ReportService{

    public $requestId;

    public $orderInfo;
    public $userInfo;
    public $goodsInfo;
    public $requestCode;

    public $url;

    const Source = 'weixin';

    const RequestCodeAdd = 'addOrder';//添加订单数据
    const RequestCodePickUp = 'pickupOrder';//取货订单数据
    const RequestCodeRefund = 'refundOrder';//退货订单数据

    const PickupMode = 1;//1线下取货2邮寄
    const PostMode = 2;

    const OrderStatusPrepaid = 1;//1已支付2已取货3已退款
    const OrderStatusPicked = 2;
    const OrderStatusRefunded = 3;

    const MachineBuyMode = 1;//1：机器购买2：小程序
    const AppBuyMode = 2;

    const AliPayMode = 1;//1：支付宝2：微信 3:会员 4会员微信 5八贝币
    const WeiXinPayMode = 2;
    const BalancePayMode = 3;
    const WxPayMode = 4;
    const EightCashPayMode = 5;

    const Tourist = 1;     //用户类型 1游客2粉丝3会员
    const User = 2;
    const VIPUser = 3;

    const VIP = '会员';
    const FullReduction = '满减';
    const Coupon = '优惠券';
    const EightCash = '八贝币';

    public function __construct($order_no,$request_code)
    {
        $this->requestCode = $request_code;

        $this->orderInfo = Order::where('online_order',$order_no)->first()->toArray();

        $this->goodsInfo = OrderGoods::where('order_no',$order_no)->get()->toArray();

        $this->userInfo = User::with(['inviteUserInfo','account'])->find($this->orderInfo['user_id'])->toArray();

        $this->requestId = Uuid::uuid1()->toString();

        $this->url = config('offlineApi.domain') . ':' . config('offlineApi.port.orderment') . '/center/inlet';
    }

}